<?php
define('_ROOT',dirname(dirname(__FILE__)));
define('_LIB', _ROOT . _DS . 'lib' . _DS);
set_include_path(get_include_path() . PATH_SEPARATOR . _LIB);//include lib dir
require_once 'class.G.php';
define('__T_PAGE_START_', G::microtime());
$C = G::parseIni(dirname(__FILE__) . _DS . 'config.ini');//load configuration
if (!$C['site']) die('Site is off.');//site closed
if (!$C['debug'] && !isset($_REUUEST['phpdebug'])) {//debug
	ini_set('display_errors', 'off');
	error_reporting(~E_ALL);
} else {
	ini_set('display_errors', 'on');
	error_reporting(E_ALL);
}
define('_CACHE', $C['cache']);
define('_ENCODE', $C['encode']);
define('_EXT', $C['ext']);
define('_TPL', _ROOT . _DS . 'tpl' . _DS . $C['theme'] . _DS);
define('_SUBDOMAIN',$C['subdomain']);
if (_SUBDOMAIN) {//use subdomain for channel?
	$channel = isset($_SERVER['HTTP_HOST']) ? array_shift(explode('.', $_SERVER['HTTP_HOST'])) : '';
} else {
	$channel = array_shift(explode('/', substr(G::uri(), 1)));
	//$_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'],1+strlen(_CHANNEL));
}
define('_CHANNEL', $channel ? $channel : 'www');
set_include_path(get_include_path() . PATH_SEPARATOR . _TPL);//include tpl dir
unset($C);//clean